import 'package:equatable/equatable.dart';
import 'package:website.core/core/domain/entities/purchased_subscription.dart';
import 'package:website.core/core/domain/entities/web/web_purchased_item.dart';
import 'package:website.core/core/domain/entities/web/web_purchased_subscription_status.dart';

class WebPurchasedSubscription extends Equatable
    implements WebPurchasedItem, PurchasedSubscription {
  const WebPurchasedSubscription({
    required this.purchaseItemSku,
    required this.expirationTime,
    required this.autoRenewalEnabled,
    required this.originalTransactionId,
    required this.status,
  });

  @override
  final String purchaseItemSku;

  @override
  final DateTime? expirationTime;

  @override
  final bool autoRenewalEnabled;

  final String originalTransactionId;
  final WebPurchasedSubscriptionStatus status;

  @override
  List<Object?> get props {
    return [
      originalTransactionId,
      purchaseItemSku,
      autoRenewalEnabled,
      status,
      expirationTime,
    ];
  }

  WebPurchasedSubscription copyWith({
    String Function()? purchaseItemSku,
    String Function()? originalTransactionId,
    bool Function()? autoRenewalEnabled,
    WebPurchasedSubscriptionStatus Function()? status,
    DateTime? Function()? expirationTime,
  }) {
    return WebPurchasedSubscription(
      purchaseItemSku: purchaseItemSku == null ? this.purchaseItemSku : purchaseItemSku(),
      originalTransactionId:
          originalTransactionId == null ? this.originalTransactionId : originalTransactionId(),
      autoRenewalEnabled:
          autoRenewalEnabled == null ? this.autoRenewalEnabled : autoRenewalEnabled(),
      status: status == null ? this.status : status(),
      expirationTime: expirationTime == null ? this.expirationTime : expirationTime(),
    );
  }
}
